package com.fhz.shop.intercepter;

import com.tencent.mmkv.MMKV;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 时间:2023/8/25
 *
 * @author Mr.Feng
 * 简述: TODO
 */
public class TokenInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        //请求.
        //相应
        Request request = chain.request();
        MMKV mmkv = MMKV.defaultMMKV();
        String token = mmkv.decodeString("token", "");
        Request authorization = request.newBuilder().addHeader("Authorization", token).build();
        return chain.proceed(authorization);
    }
}
